//
//  CMURLConstant.swift
//  covermedia
//
//  Created by travel on 16/2/1.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import Foundation


public enum CMURLConstant: String {
    
    case AD = "advert"
    case deviceInfo = "setDeviceInfo"
    case postion = "setPosition"
    
    case allChannels = "getChannels"
    // 我的频道列表
    case myChannel = "getMyChannels"
    // 推荐频道列表
    case recommendChannel = "getSuggestChannels"
    // 设置我的频道
    case setMyChannel = "setMyChannels"
    // 关注专栏
    case addChannel = "addChannel"
    // 取消关注专栏
    case deleteChanel = "delChannel"
    // 最近阅读
    case readHistory = "getHistoryList"
    // 我的收藏
    case myFavorite = "getMyCollection"
    //  已订阅的专栏
    case getSubjectList = "getSubject"
    //全部专栏
    case getAllSubject = "getAllSubject"
    // 新闻盒子
    case getFaceList = "getFaceList"
    case getSelections = "getSelections"
    case getDetail = "getDetail"
    case dynamic = "getDynamic"
    case getRelatedNews = "getRelatedNews"
    
    //订阅更多专栏或封面号
    case getMoreSubject = "getMoreSubject"
    
    case getFmAccounts = "getFmAccounts"       //获取推荐封面号  REMOVE
    case getAllFmChannels = "getAllFmChannels" //获取所有封面号频道 REMOVE
    case getFmChannel = "getFmChannel" //得到封面号列表
    case getCoverList = "getCoverList"         //得到封面号新闻列表 
    
    //直播
    case getLiveList = "getLiveList"           //得到直播列表
    case getBookLiveList = "getBookLiveList"    //直播预告列表
    case bookLive = "bookLive"  //订阅或取消预告
    //集合推送
    case getPushList = "getPushList"
    //获取热门搜索
    case hotSearch = "getHotSearch"
    //执行搜索功能
    case search = "search"
    // 修改个人资料
    case modifyProfile = "updateUserInfo"
    // 修改密码
    case modifyPassword = "modifyPwd"
    // 上传图片
    case uploadImage = "uploadImg"
    case getFmDailyImg = "getFmDailyImg"
    //获取已订阅专栏 & 封面号
    case getMySubject = "getMySubject"
    //登录 & 注册
    case login = "login"
    case quickLogin = "quickLogin"
    case register = "regPhone"
    case forgetPassword = "forgetPwd"
    case resetPassword = "resetPwd"
    case collect = "collect"
    case share = "share"
    case praise = "praise"
    
    case resetMessage = "resetMessage" //清除我的消息通知数量
    case getSysnotice = "getSysnotice" //系统通知
    case getReplyToMe = "getReplyToMe" //我的消息- 评论
    case getPraiseToMe = "getPraiseToMe" //我收到的点赞
    case getMessageCount = "getMessageCount" //获取消息数量
    //评论列表
    case replyList = "getReplyList"
    //评论添加
    case reply = "reply"
    //评论删除
    case replyDel = "delReply"
    //评论赞
    case replyPraise = "praiseReply"
    
    case bindMobile = "bindingMobile"
    case sendCode = "sendVcode"
    case getMyMessage = "getMyMessage"
    case sendMyFeedBack = "sendMyFeedBack"
    case offline = "offline"
    case track = "track"
    case getFmDaily = "getFmDaily"
    case getCrowds = "getCrowds"
    case setCrowds = "setCrowds"
    case getLatestVersion = "getLatestVersion"
    case delDislikeNews = "delDislikeNews"
    case checkWords = "checkWords"
    case checkAvatar = "checkAvatar"
    case orderFmDaily = "orderFmDaily"
    case cancelCustom = "cancelCustom"
    case isSubscribed = "isSubscribed"
    
    case activityCenter = "activityCenter"
    case about = "http://m.thecover.cn/about_wap.html"
    case agreement = "http://m.thecover.cn/pact.html"
    case downloadApp = "http://m.thecover.cn/downloadApp.html"
    case settleCoverAccount = "http://m.thecover.cn/intro_fengmianhao.html"
    
    case callBackWeiboLogin = "http://www.thecover.cn/callBack/weibo"
    
    case checkLiveStatus = "live/checkLiveStatus"

    
    case reachabilityHost = "www.baidu.com"
    
    case getNextSubject = "getNextSubject"
    
    case liveChat = "live/app?"
    
    // 记录转发信息
    case forward = "forward"
    
    // 邀请码:
    case getInviteCodeInfo = "getInviteCodeInfo"
    case setInviteCodeInfo = "setInviteCodeInfo"
    
    
    // 激活设备信息
    case activateDeviceData = "activateDeviceData"

    public var urlConstant: String {
        switch self {
        case .activityCenter:
            return kAppEnv == .product ? "http://h5.thepage.cn/activity/index.html" : "http://mtest.thecover.cn/activity/index.html"
        case .about, .agreement, .downloadApp, .settleCoverAccount, .callBackWeiboLogin:
            return self.rawValue
        case .liveChat:
            return CMURLConstant.LiveHost + rawValue
        case .reachabilityHost:
            return self.rawValue
        default:
            return CMURLConstant.Host + rawValue
        }
    }
    public var urlLocalConstant: String {
        return "http://localhost:1024/" + rawValue
    }
}

public extension CMURLConstant {
    public static var Host: String {
        switch kAppEnv {
        case .product:
            return "https://api.thecover.cn/"
        case .test:
            return "http://121.41.11.40/"
        case .pubTest:
            return "http://120.26.104.64:8081/"
        }
    }
    
    public static var LiveHost: String {
        switch kAppEnv {
        case .product:
            return "ws://livecast.thecover.cn/"
        case .test:
            return "ws://114.55.139.161:8086/"
        case .pubTest:
            return "ws://114.55.139.161:8086/"
        }
    }
    
    public static func serviceApi(_ path: String) -> String {
        return self.Host + path
    }
    
}
